using System;
using System.Collections.Generic;

namespace FishFillets.Data.levels
{
    public partial class wc : BaseLevelScript
    {
        // ---------------------------------------------------------------
        // Init
        // ---------------------------------------------------------------
        public override void prog_init()
        {
            pokus = getRestartCount();

            // -----------------------------------------------------------
            Func<Action> prog_init_room = (() =>
            {
                int pom1 = 0;
                int pom2 = 0;
                bool pomb1 = false;
                bool pomb2 = false;

                if (pokus == 1 || random(100) < 50)
                {
                    room.uvod = 1;
                    room.druha = random(2) + 2;
                }
                else
                {
                    room.uvod = 2;
                    room.druha = random(2) * 2 + 1;
                }
                room.omise = 0;
                room.timerdruhe = random(1000) + 500;

                return (() =>
                {
                    if (no_dialog() && isReady(small) && isReady(big))
                    {
                        if (room.timerdruhe > 0)
                        {
                            room.timerdruhe = room.timerdruhe - 1;
                        }
                        pom1 = 0;
                        if (room.uvod > 0)
                        {
                            pom1 = room.uvod;
                            room.uvod = 0;
                            if (pokus != 1)
                            {
                                adddel(random(500) + 20);
                            }
                            else
                            {
                                adddel(random(20) + 20);
                            }
                        }
                        else if (room.timerdruhe == 0)
                        {
                            pom1 = room.druha;
                            room.timerdruhe = -1;
                            adddel(30);
                        }
                        else if (room.omise == 0 && small.Y >= 19)
                        {
                            room.omise = 1;
                            addm(10 + random(30), "wc-m-vlezt");
                        }
                        if (pom1 > 0)
                        {
                            switch (pom1)
                            {
                                case 1:
                                    addm(0, "wc-m-prasecinky");
                                    addv(random(10), "wc-v-hygiena");
                                    break;
                                case 2:
                                    addm(0, "wc-m-hrbitov");
                                    addv(random(5), "wc-v-coze");
                                    addm(random(10) + 5, "wc-m-nevis");
                                    break;
                                case 3:
                                    addv(0, "wc-v-oblibene");
                                    addm(0, "wc-m-coze");
                                    addv(5, "wc-v-neznas");
                                    addm(5, "wc-m-sochar");
                                    addv(10, "wc-v-zmatek");
                                    break;
                            }
                        }
                    }
                });
            });

            // -----------------------------------------------------------
            update_table = new List<Action> { prog_init_room() };
        }
    }
}
